package com.xijia.wuyouwallet.activity;

import android.annotation.TargetApi;
import android.content.ActivityNotFoundException;
import android.content.ContentUris;
import android.content.ContentValues;
import android.content.Context;
import android.content.Intent;
import android.database.Cursor;
import android.graphics.Bitmap;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.os.Environment;
import android.provider.DocumentsContract;
import android.provider.MediaStore;
import android.support.annotation.Nullable;
import android.support.v4.content.FileProvider;
import android.util.Log;
import android.view.Gravity;
import android.view.View;
import android.widget.ImageView;
import android.widget.PopupWindow;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;

import com.alibaba.fastjson.JSONObject;
import com.squareup.picasso.Picasso;
import com.xijia.wuyouwallet.MyApp;
import com.xijia.wuyouwallet.R;
import com.xijia.wuyouwallet.api.MyCallBack;
import com.xijia.wuyouwallet.base.BaseActivity;
import com.xijia.wuyouwallet.bean.UpLoadImgData;
import com.xijia.wuyouwallet.utils.Constants;
import com.xijia.wuyouwallet.utils.FileUtil;
import com.xijia.wuyouwallet.utils.MyLogger;
import com.xijia.wuyouwallet.utils.StringUtils;
import com.xijia.wuyouwallet.utils.UrlConfig;
import com.xijia.wuyouwallet.utils.XUtil;

import java.io.File;
import java.io.IOException;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;

import cn.sharesdk.framework.Platform;
import cn.sharesdk.framework.PlatformActionListener;
import cn.sharesdk.framework.ShareSDK;
import cn.sharesdk.wechat.friends.Wechat;
import de.hdodenhof.circleimageview.CircleImageView;

/**
 * Created by Administrator on 2017/7/15 0015.
 */

public class PersonInfoActivity extends BaseActivity implements View.OnClickListener{


    private  String cachPath;

    private  File cacheFile;
    private  File cameraFile;

    private Uri imageUri;

    private ImageView personInfo_back;
    private CircleImageView personInfo_icon;
    private RelativeLayout personInfo_nickName_rl,personInfo_businessNum_rl,personInfo_attestation_rl
            ,personInfo_phoneNum_rl,personInfo_weixin_rl,personInfo_alipay_rl,personInfo_member_rl;

    private TextView personInfo_nickName_tv,personInfo_businessNum_tv,personInfo_attestation_tv,
            personInfo_phoneNum_tv,personInfo_weixin_tv,personInfo_alipay_tv,personInfo_member_tv;

    //选择头像
    private PopupWindow selectUserPhotoPop;
    private RelativeLayout layout_rl_tilte;

    private final int REQUESTCODE_TAKE = 11;                // 拍照
    private final int REQUESTCODE_CUTTING = 31;            // 结果
    private final int REQUESTCODE_PICK = 21;             //相册选取
    private String urlpath; // 图片本地路径

    private String openid;
    private Platform wechat;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_personal_info);
        initView();
    }
    private void initView(){
        personInfo_back = (ImageView) findViewById(R.id.personInfo_back);
        personInfo_back.setOnClickListener(this);
        personInfo_icon = (CircleImageView) findViewById(R.id.personInfo_icon);
        personInfo_icon.setOnClickListener(this);
        personInfo_nickName_rl = (RelativeLayout) findViewById(R.id.personInfo_nickName_rl);
        personInfo_nickName_rl.setOnClickListener(this);
        personInfo_businessNum_rl = (RelativeLayout) findViewById(R.id.personInfo_businessNum_rl);
        personInfo_businessNum_rl.setOnClickListener(this);
        personInfo_attestation_rl = (RelativeLayout) findViewById(R.id.personInfo_attestation_rl);
        personInfo_attestation_rl.setOnClickListener(this);
        personInfo_phoneNum_rl = (RelativeLayout) findViewById(R.id.personInfo_phoneNum_rl);
        personInfo_phoneNum_rl.setOnClickListener(this);
        personInfo_weixin_rl = (RelativeLayout) findViewById(R.id.personInfo_weixin_rl);
        personInfo_weixin_rl.setOnClickListener(this);
        personInfo_alipay_rl = (RelativeLayout) findViewById(R.id.personInfo_alipay_rl);
        personInfo_alipay_rl.setOnClickListener(this);
        personInfo_member_rl = (RelativeLayout) findViewById(R.id.personInfo_member_rl);
        personInfo_member_rl.setOnClickListener(this);

        personInfo_nickName_tv = (TextView) findViewById(R.id.personInfo_nickName_tv);
        personInfo_businessNum_tv = (TextView) findViewById(R.id.personInfo_businessNum_tv);
        personInfo_attestation_tv = (TextView) findViewById(R.id.personInfo_attestation_tv);
        personInfo_phoneNum_tv = (TextView) findViewById(R.id.personInfo_phoneNum_tv);
        personInfo_weixin_tv = (TextView) findViewById(R.id.personInfo_weixin_tv);
        personInfo_alipay_tv = (TextView) findViewById(R.id.personInfo_alipay_tv);
        personInfo_member_tv = (TextView) findViewById(R.id.personInfo_member_tv);

        layout_rl_tilte = (RelativeLayout) findViewById(R.id.layout_rl_tilte);

        initData();
    }
    private void initData(){
        personInfo_nickName_tv.setText(MyApp.userData.getData().getNick_name());
        personInfo_businessNum_tv.setText(MyApp.userData.getData().getUser_no());
        if (MyApp.userData.getData().getCertification_state().equals("1")){
            personInfo_attestation_tv.setText("已认证");
            personInfo_attestation_tv.setTextColor(getResources().getColor(R.color.main_orange));
        }else {
            personInfo_attestation_tv.setText("未认证");
            personInfo_attestation_tv.setTextColor(getResources().getColor(R.color.font2));
        }
        personInfo_phoneNum_tv.setText(StringUtils.hintPhone(MyApp.userData.getData().getPhone()));
        //会员等级
        personInfo_member_tv.setText(MyApp.userData.getData().getRole());
        //头像
        if (MyApp.userData.getData().getAvata()!=null||!MyApp.userData.getData().getAvata().equals("")){
            Picasso.with(this).load(MyApp.userData.getData().getAvata()).fit().into(personInfo_icon);
        }
        if (MyApp.userData.getData().getAccount_info().getAlipay().getState()==0){
            personInfo_alipay_tv.setText("未认证");
            personInfo_alipay_tv.setTextColor(getResources().getColor(R.color.font2));
        }else {
            personInfo_alipay_tv.setText("已绑定");
            personInfo_alipay_tv.setTextColor(getResources().getColor(R.color.main_orange));
        }
        if (MyApp.userData.getData().getAccount_info().getWeipay().getState()==0){
            personInfo_weixin_tv.setText("未认证");
            personInfo_weixin_tv.setTextColor(getResources().getColor(R.color.font2));
        }else {
            personInfo_weixin_tv.setText("已绑定");
            personInfo_weixin_tv.setTextColor(getResources().getColor(R.color.main_orange));
        }
        cachPath=getDiskCacheDir(this)+ "/crop_image.jpg";
        cacheFile =getCacheFile(new File(getDiskCacheDir(this)),"crop_image.jpg");
    }
    //初始化改换头像popup
    private void initUserPhotoPop() {
        View popView = View.inflate(this, R.layout.popup_select_picture, null);
        selectUserPhotoPop = new PopupWindow(RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT);
        TextView popup_select_tv_photograph = (TextView) popView.findViewById(R.id.popup_select_tv_photograph);
        TextView popup_select_tv_album = (TextView) popView.findViewById(R.id.popup_select_tv_album);
        TextView popup_select_tv_cancel = (TextView) popView.findViewById(R.id.popup_select_tv_cancel);
        RelativeLayout popup_select_rl_all = (RelativeLayout) popView.findViewById(R.id.popup_select_rl_all);
        popup_select_rl_all.getBackground().setAlpha(150);
        popup_select_rl_all.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                selectUserPhotoPop.dismiss();
            }
        });
        //拍照
        popup_select_tv_photograph.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                selectUserPhotoPop.dismiss();
                //Intent takeIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
                //下面这句指定调用相机拍照后的照片存储的路径
                //takeIntent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(new File(Environment.getExternalStorageDirectory(),
                 //       IMAGE_FILE_NAME)));
                //startActivityForResult(takeIntent, REQUESTCODE_TAKE);
                cameraFile = getCacheFile(new File(getDiskCacheDir(PersonInfoActivity.this)),"output_image.jpg");
                Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
                if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N) {
                    imageUri = Uri.fromFile(cameraFile);
                } else {
                    intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
                    imageUri = FileProvider.getUriForFile(PersonInfoActivity.this, "com.xijia.fuyingwallet.fileprovider", cameraFile);
                }
                // 启动相机程序
                intent.putExtra(MediaStore.EXTRA_OUTPUT, imageUri);
                startActivityForResult(intent, REQUESTCODE_TAKE);
            }
        });
        //从相册选取
        popup_select_tv_album.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                selectUserPhotoPop.dismiss();
                //Intent intent = new Intent(Intent.ACTION_PICK, null);
                //intent.setDataAndType(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, IMAGE_UNSPECIFIED);
                //startActivityForResult(Intent.createChooser(intent, "请选择图片"), REQUESTCODE_PICK);
                //startActivityForResult(intent, REQUESTCODE_PICK);
                Intent intent = new Intent("android.intent.action.GET_CONTENT");
                intent.setType("image/*");
                startActivityForResult(intent, REQUESTCODE_PICK); // 打开相册
            }
        });
        popup_select_tv_cancel.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                selectUserPhotoPop.dismiss();
            }
        });
        selectUserPhotoPop.setContentView(popView);
    }
    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        if (requestCode == Constants.REQUEST_DATA&&resultCode==Constants.RESULT_DATA){
            //Log.e("info","准备刷新数据");
            initData();
        }
        if (resultCode != RESULT_CANCELED) {
            switch (requestCode) {
                case REQUESTCODE_PICK:
                    //startPhotoZoom(data.getData());
                    // 判断手机系统版本号
                    if (Build.VERSION.SDK_INT >= 19) {
                        // 4.4及以上系统使用这个方法处理图片
                        handleImageOnKitKat(data);
                    } else {
                        // 4.4以下系统使用这个方法处理图片
                        handleImageBeforeKitKat(data);
                    }
                    break;
                case REQUESTCODE_TAKE:
                   // File temp = new File(Environment.getExternalStorageDirectory() + "/" + IMAGE_FILE_NAME);
                   // startPhotoZoom(Uri.fromFile(temp));
                    startPhotoZoom(cameraFile,350);
                    break;
                case REQUESTCODE_CUTTING://取得裁剪后的图片
                    /*if (data != null) {
                        setPicToView(data);
                    }else {
                        Log.e("info","裁剪完图片为空");
                    }*/
                    //setPicToView();
                    upLoad();
                    break;
            }
        }
    }
    @TargetApi(19)
    private void handleImageOnKitKat(Intent data) {
        Uri uri = data.getData();
        Log.d("TAG", "handleImageOnKitKat: uri is " + uri);
        String imagePath= uriToPath(uri);
        startPhotoZoom(new File(imagePath),350);
    }
    private void handleImageBeforeKitKat(Intent data) {
        Uri uri = data.getData();
        String imagePath = getImagePath(uri, null);
//        displayImage(imagePath);
        Log.i("TAG","file://"+imagePath+"选择图片的URI"+uri);
        startPhotoZoom(new File(imagePath),350);
    }
    /**
     * 上传图片到服务器
     */
    private void upLoad(){
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("token",MyApp.userData.getData().getToken());
        map.put("user",MyApp.userData.getData().getUser_id());
        //map.put("headImg", new File(urlpath));
        map.put("headImg", new File(cachPath));
        showProgressDialog(true);
        XUtil.UpLoadFile(UrlConfig.UP_HEADIMG_URL, map, new MyCallBack<String>() {
            @Override
            public void onSuccess(String result) {
                super.onSuccess(result);
                dismissProgressDialog();
                MyLogger.wLog().e("上传图片result=" + result);
                UpLoadImgData upLoadImgData = JSONObject.parseObject(result, UpLoadImgData.class);
                if (upLoadImgData.getCode() == 200) {
                    upHeadImg(upLoadImgData.getData().getUrl());
                } else {
                    showToast(upLoadImgData.getMsg());
                }

            }
            @Override
            public void onError(Throwable ex, boolean isOnCallback) {
                super.onError(ex, isOnCallback);
                dismissProgressDialog();
                showToast("头像修改失败");
            }
        });
    }

    /**
     * 裁剪图片方法实现
     *
     * @param uri
     */
    public void startPhotoZoom(Uri uri) {
        Log.e("info","进入裁剪图片");
        Intent intent = new Intent("com.android.camera.action.CROP");
        intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
        intent.setDataAndType(uri, "image/*");
        // crop=true是设置在开启的Intent中设置显示的VIEW可裁剪
        intent.putExtra("crop", "true");
        // aspectX aspectY 是宽高的比例
        intent.putExtra("aspectX", 1);
        intent.putExtra("aspectY", 1);
        // outputX outputY 是裁剪图片宽高
        intent.putExtra("outputX", 300);
        intent.putExtra("outputY", 300);
        intent.putExtra("return-data", true);
        startActivityForResult(intent, REQUESTCODE_CUTTING);
    }
    /**
     * 剪裁图片
     */
    private void startPhotoZoom(File file, int size) {
        try {
            Intent intent = new Intent("com.android.camera.action.CROP");
            intent.setDataAndType(getImageContentUri(this,file), "image/*");//自己使用Content Uri替换File Uri
            intent.putExtra("crop", "true");
            intent.putExtra("aspectX", 1);
            intent.putExtra("aspectY", 1);
            intent.putExtra("outputX", 180);
            intent.putExtra("outputY", 180);
            intent.putExtra("scale", true);
            intent.putExtra("return-data", false);
            intent.putExtra(MediaStore.EXTRA_OUTPUT,Uri.fromFile(cacheFile));//定义输出的File Uri
            intent.putExtra("outputFormat", Bitmap.CompressFormat.JPEG.toString());
            intent.putExtra("noFaceDetection", true);
            startActivityForResult(intent, REQUESTCODE_CUTTING);
        } catch (ActivityNotFoundException e) {
            String errorMessage = "Your device doesn't support the crop action!";
            Toast.makeText(this, errorMessage, Toast.LENGTH_LONG).show();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    public static Uri getImageContentUri(Context context, File imageFile) {
        String filePath = imageFile.getAbsolutePath();
        Cursor cursor = context.getContentResolver().query(
                MediaStore.Images.Media.EXTERNAL_CONTENT_URI,
                new String[] { MediaStore.Images.Media._ID },
                MediaStore.Images.Media.DATA + "=? ",
                new String[] { filePath }, null);

        if (cursor != null && cursor.moveToFirst()) {
            int id = cursor.getInt(cursor
                    .getColumnIndex(MediaStore.MediaColumns._ID));
            Uri baseUri = Uri.parse("content://media/external/images/media");
            return Uri.withAppendedPath(baseUri, "" + id);
        } else {
            if (imageFile.exists()) {
                ContentValues values = new ContentValues();
                values.put(MediaStore.Images.Media.DATA, filePath);
                return context.getContentResolver().insert(
                        MediaStore.Images.Media.EXTERNAL_CONTENT_URI, values);
            } else {
                return null;
            }
        }
    }
    @TargetApi(Build.VERSION_CODES.KITKAT)
    private String uriToPath(Uri uri) {
        String path=null;
        if (DocumentsContract.isDocumentUri(this, uri)) {
            // 如果是document类型的Uri，则通过document id处理
            String docId = DocumentsContract.getDocumentId(uri);
            if("com.android.providers.media.documents".equals(uri.getAuthority())) {
                String id = docId.split(":")[1]; // 解析出数字格式的id
                String selection = MediaStore.Images.Media._ID + "=" + id;
                path = getImagePath(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, selection);
            } else if ("com.android.providers.downloads.documents".equals(uri.getAuthority())) {
                Uri contentUri = ContentUris.withAppendedId(Uri.parse("content://downloads/public_downloads"), Long.valueOf(docId));
                path = getImagePath(contentUri, null);
            }
        } else if ("content".equalsIgnoreCase(uri.getScheme())) {
            // 如果是content类型的Uri，则使用普通方式处理
            path = getImagePath(uri, null);
        } else if ("file".equalsIgnoreCase(uri.getScheme())) {
            // 如果是file类型的Uri，直接获取图片路径即可
            path = uri.getPath();
        }
        return  path;
    }
    private String getImagePath(Uri uri, String selection) {
        String path = null;
        // 通过Uri和selection来获取真实的图片路径
        Cursor cursor = getContentResolver().query(uri, null, selection, null, null);
        if (cursor != null) {
            if (cursor.moveToFirst()) {
                path = cursor.getString(cursor.getColumnIndex(MediaStore.Images.Media.DATA));
            }
            cursor.close();
        }
        return path;
    }

    public String getDiskCacheDir(Context context) {
        String cachePath = null;
        if (Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState())
                || !Environment.isExternalStorageRemovable()) {
            cachePath = context.getExternalCacheDir().getPath();
        } else {
            cachePath = context.getCacheDir().getPath();
        }
        return cachePath;
    }

    private  File getCacheFile(File parent, String child) {
        // 创建File对象，用于存储拍照后的图片
        File file = new File(parent, child);

        if (file.exists()) {
            file.delete();
        }
        try {
            file.createNewFile();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return file;
    }

    /**
     * 保存裁剪之后的图片数据
     *
     * @param picdata
     */
    private void setPicToView(Intent picdata) {
        Bundle extras = picdata.getExtras();
        if (extras != null) {
            //取得SDCard图片路径做显示
            Bitmap photo = extras.getParcelable("data");
            Log.e("info","photo="+photo.toString());
            //Drawable drawable = new BitmapDrawable(null, photo);
            urlpath = FileUtil.saveFile(PersonInfoActivity.this, "fuyingHead.jpg", photo);
            //basics_civ_user_icon.setImageDrawable(drawable);
            Log.e("info","上传urlpath="+urlpath);
            Map<String, Object> map = new HashMap<String, Object>();
            map.put("token",MyApp.userData.getData().getToken());
            map.put("user",MyApp.userData.getData().getUser_id());
            //Log.e("info","token="+MyApp.userData.getData().getToken());
            //Log.e("info","token="+MyApp.userData.getData().getUser_id());
            map.put("headImg", new File(urlpath));
            //showProgressDialog();
            XUtil.UpLoadFile(UrlConfig.UP_HEADIMG_URL, map, new MyCallBack<String>() {
                @Override
                public void onSuccess(String result) {
                    super.onSuccess(result);
                    MyLogger.wLog().e("上传图片result=" + result);
                    UpLoadImgData upLoadImgData = JSONObject.parseObject(result, UpLoadImgData.class);
                    if (upLoadImgData.getCode() == 200) {
                       upHeadImg(upLoadImgData.getData().getUrl());
                    } else {
                        showToast(upLoadImgData.getMsg());
                    }

                }
                @Override
                public void onError(Throwable ex, boolean isOnCallback) {
                    super.onError(ex, isOnCallback);
                    //dismissProgressDialog();
                    showToast("头像修改失败");
                    //Log.e("info","Throwable="+ex.toString());
                }
            });
        }
    }

    /**
     * 修改头像
     */
    private void upHeadImg(final String img){
        Map<String,Object> map = new HashMap<>();
        map.put("token",MyApp.userData.getData().getToken());
        map.put("user",MyApp.userData.getData().getUser_id());
        map.put("avata",img);
        XUtil.Post(UrlConfig.AMEND_HEADIMG_URL,map,new MyCallBack<String>(){

            @Override
            public void onSuccess(String result) {
                super.onSuccess(result);
                //MyLogger.wLog().e("修改头像result="+result);
                JSONObject jsonObject = JSONObject.parseObject(result);
                if (jsonObject.getInteger("code")==200){
                    Picasso.with(PersonInfoActivity.this).load(img).fit().into(personInfo_icon);
                    MyApp.userData.getData().setAvata(img);
                    MyApp.isRefresh = true;
                }
                showToast(jsonObject.getString("msg"));
            }

            @Override
            public void onError(Throwable ex, boolean isOnCallback) {
                super.onError(ex, isOnCallback);
                MyLogger.wLog().e("修改头像失败");
            }
        });
    }
    //执行授权,获取用户信息
    //文档：http://wiki.mob.com/Android_%E8%8E%B7%E5%8F%96%E7%94%A8%E6%88%B7%E8%B5%84%E6%96%99
    private void authorize(Platform plat) {
        if (plat == null) {
            return;
        }
        plat.setPlatformActionListener(new PlatformActionListener() {
            @Override
            public void onComplete(Platform platform, int i, HashMap<String, Object> hashMap) {
                Iterator ite = hashMap.entrySet().iterator();
                while (ite.hasNext()) {
                    Map.Entry entry = (Map.Entry) ite.next();
                    //Object key = entry.getKey();
                    //Object value = entry.getValue();
                    //System.out.println(key+"： "+value);
                    //Log.e("info","key="+key+"value="+value);
                    if (entry.getKey().toString().equals("openid")) {
                        openid = entry.getValue().toString();
                    }
                }
                //        Log.e("info", "openid=" + openid);
                boundWx(openid);
            }

            @Override
            public void onError(Platform platform, int i, Throwable throwable) {

            }

            @Override
            public void onCancel(Platform platform, int i) {

            }
        });
        //关闭SSO授权
        plat.SSOSetting(true);
        plat.showUser(null);
    }
    private void boundWx(final String openid){
        Map<String,Object> map = new HashMap<>();
        map.put("token",MyApp.userData.getData().getToken());
        map.put("user",MyApp.userData.getData().getUser_id());
        map.put("pay_type_code","weipay");
        map.put("pay_type_name","微信");
        map.put("account",openid);
        //map.put("other_info","");
        XUtil.Post(UrlConfig.BINDING_WX_APLIPAY_URL,map,new MyCallBack<String>(){
            @Override
            public void onSuccess(String result) {
                super.onSuccess(result);
                //MyLogger.wLog().e("绑定微信返回result="+result);
                JSONObject jsonObject = JSONObject.parseObject(result);
                if (jsonObject.getInteger("code")==200){
                    MyApp.userData.getData().getAccount_info().getWeipay().setState(1);
                    MyApp.userData.getData().getAccount_info().getWeipay().setAccount(openid);
                    if (wechat.isAuthValid()) {
                        wechat.removeAccount(true);
                    }
                    initData();
                }else {
                    if (wechat.isAuthValid()) {
                        wechat.removeAccount(true);
                    }
                }

                showToast(jsonObject.getString("msg"));
            }

            @Override
            public void onError(Throwable ex, boolean isOnCallback) {
                super.onError(ex, isOnCallback);
                MyLogger.wLog().e("绑定微信失败");
                if (wechat.isAuthValid()) {
                    wechat.removeAccount(true);
                }
            }
        });
    }
    @Override
    public void onClick(View view) {
        switch (view.getId()){
            case R.id.personInfo_back:
                finish();
                break;
            case R.id.personInfo_icon:
                if (selectUserPhotoPop == null) {
                    initUserPhotoPop();
                }
                selectUserPhotoPop.showAtLocation(layout_rl_tilte, Gravity.TOP, 0, 0);
                break;
            case R.id.personInfo_nickName_rl:
                //jumpToPage(UpnickNameActivity.class,true, Constants.REQUEST_DATA);
                break;
            case R.id.personInfo_businessNum_rl:

                break;
            case R.id.personInfo_attestation_rl:
                if (MyApp.userData.getData().getCertification_state().equals("0")){
                    jumpToPage(AttestationActivity.class,true,Constants.REQUEST_DATA);
                }else if (MyApp.userData.getData().getCertification_state().equals("1")){
                    jumpToPage(AttestationSuccessActivity.class);
                }
                break;
            case R.id.personInfo_phoneNum_rl:

                break;
            case R.id.personInfo_weixin_rl://绑定微信
                if (MyApp.userData.getData().getAccount_info().getWeipay().getState()==0){
                    wechat = ShareSDK.getPlatform(Wechat.NAME);
                    authorize(wechat);
                }else {
                    Bundle bundle = new Bundle();
                    bundle.putString("type","weipay");
                    jumpToPage(RelieveAcountActivity.class,bundle,true,Constants.REQUEST_DATA,false);
                }
                break;
            case R.id.personInfo_alipay_rl://绑定支付宝
                if (MyApp.userData.getData().getAccount_info().getAlipay().getState()==0){
                    jumpToPage(AplipayBingdingActivity.class,true,Constants.REQUEST_DATA);
                }else {
                    Bundle bundle = new Bundle();
                    bundle.putString("type","alipay");
                    jumpToPage(RelieveAcountActivity.class,bundle,true,Constants.REQUEST_DATA,false);
                }
                break;
            case R.id.personInfo_member_rl:

                break;
        }
    }



}
